package com.rh.controller;

import com.rh.Enums;
import com.rh.dto.Result;
import com.rh.entity.SubjectType;
import com.rh.excrptions.DoException;
import com.rh.service.SubjectTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@CrossOrigin
@Controller
@ResponseBody
public class SubjectTypeController {
    @Autowired
    private SubjectTypeService subjectTypeService;

    /**
     * 查询所有类型
     * @return
     */
    @RequestMapping("/getSubjectType")
    public Result getSubjectType() {
        try {
            List<SubjectType> subjectAll = subjectTypeService.getSubjectAll();
            Result result = new Result();
            result.setData(subjectAll);
            return result;
        }catch (Exception e){
            throw new DoException(Enums.GETLIST_ERROR);
        }
    }
}
